/******************************************************************************
 * FileName:    gwin_global_config.c
 * Desc:        参数配置
 *
 *
 * Author:      Lin
 * Notes:
 *
 ******************************************************************************/

/*-------------------------- Includes ---------------------------------------*/
#include "gwin_global_config.h"
#include "gwin_main_task.h"


/*-------------------------- Macro Definitions ------------------------------*/
#define LOCAL_DEBUG_EN                      ( 0 )
#if LOCAL_DEBUG_EN
#define GWIN_DEBUG(...)                     USER_DEBUG(__VA_ARGS__)
#else
#define GWIN_DEBUG(...)
#endif


/*-------------------------- Type Declarations ------------------------------*/

/*-------------------------- Global Variables -------------------------------*/

/*-------------------------- Local Variables --------------------------------*/

/*-------------------------- Functions Declarations -------------------------*/

/*-------------------------- Functions Definitions --------------------------*/
/**
 * @brief 设置配网
 */
void gwin_set_network_provisioned(uint8_t value)
{
    GWIN_DEBUG("%d", value);

    gwin_main_cfg_set(MAIN_TASK_MSG_CFG_SUBTYPE_NETWORK, value);
}

/**
 * @brief 设置蓝牙直连
 */
void gwin_set_gatt(uint8_t value)
{
    GWIN_DEBUG("%d", value);

    gwin_main_cfg_set(MAIN_TASK_MSG_CFG_SUBTYPE_GATT, value);
}

/**
 * @brief 设置ota
 */
void gwin_set_ota_state(uint8_t value)
{
    GWIN_DEBUG("%d", value);

    gwin_main_cfg_set(MAIN_TASK_MSG_CFG_SUBTYPE_OTA_STATE, value);
}

/**
 * @brief 窗帘状态
 */
void gwin_set_curtain_state(uint32_t value)
{
    GWIN_DEBUG("%d", value);

    gwin_main_cfg_set(MAIN_TASK_MSG_CFG_SUBTYPE_CURTAIN_STATE, value);
}

/**
 * @brief 当前位置
 */
void gwin_set_current_position(uint32_t value)
{
    GWIN_DEBUG("%d", value);

    gwin_main_cfg_set(MAIN_TASK_MSG_CFG_SUBTYPE_CURRENT_POSITION, value);
}

/**
 * @brief 目标位置
 */
void gwin_set_target_position(uint32_t value)
{
    GWIN_DEBUG("%d", value);

    gwin_main_cfg_set(MAIN_TASK_MSG_CFG_SUBTYPE_TARGET_POSITION, value);
}

/**
 * @brief 方向
 */
void gwin_set_direction(uint32_t value)
{
    GWIN_DEBUG("%d", value);

    gwin_main_cfg_set(MAIN_TASK_MSG_CFG_SUBTYPE_DIRECTION, value);
}

/**
 * @brief 速度等级
 */
void gwin_set_speed_level(uint32_t value)
{
    GWIN_DEBUG("%d", value);

    gwin_main_cfg_set(MAIN_TASK_MSG_CFG_SUBTYPE_SPEED_LEVEL, value);
}

/**
 * @brief 行程最小值
 */
void gwin_set_stroke_min(uint32_t value)
{
    GWIN_DEBUG("%d", value);

    gwin_main_cfg_set(MAIN_TASK_MSG_CFG_SUBTYPE_STROKE_MIN, value);
}

/**
 * @brief 行程最大值
 */
void gwin_set_stroke_max(uint32_t value)
{
    GWIN_DEBUG("%d", value);

    gwin_main_cfg_set(MAIN_TASK_MSG_CFG_SUBTYPE_STROKE_MAX, value);
}

/**
 * @brief 干节点模式
 */
void gwin_set_node_mode(uint32_t value)
{
    GWIN_DEBUG("%d", value);

    gwin_main_cfg_set(MAIN_TASK_MSG_CFG_SUBTYPE_NODE_MODE, value);
}




// 保证主任务优先级最高！！！保证低优先级任务调用！！！否则 gwin_main_cfg_get 会有问题！！！
/**
 * @brief 窗帘状态
 */
uint32_t gwin_get_curtain_state(void)
{
    uint32_t value = 0;
    gwin_main_cfg_get(MAIN_TASK_MSG_CFG_SUBTYPE_CURTAIN_STATE, (uint32_t)&value);

    GWIN_DEBUG("%d", value);

    return value;
}

/**
 * @brief 当前位置
 */
uint32_t gwin_get_current_position(void)
{
    uint32_t value = 0;
    gwin_main_cfg_get(MAIN_TASK_MSG_CFG_SUBTYPE_CURRENT_POSITION, (uint32_t)&value);

    GWIN_DEBUG("%d", value);

    return value;
}

/**
 * @brief 目标位置
 */
uint32_t gwin_get_target_position(void)
{
    uint32_t value = 0;
    gwin_main_cfg_get(MAIN_TASK_MSG_CFG_SUBTYPE_TARGET_POSITION, (uint32_t)&value);

    GWIN_DEBUG("%d", value);

    return value;
}

/**
 * @brief 方向
 */
uint32_t gwin_get_direction(void)
{
    uint32_t value = 0;
    gwin_main_cfg_get(MAIN_TASK_MSG_CFG_SUBTYPE_DIRECTION, (uint32_t)&value);

    GWIN_DEBUG("%d", value);

    return value;
}

/**
 * @brief 速度等级
 */
uint32_t gwin_get_speed_level(void)
{
    uint32_t value = 0;
    gwin_main_cfg_get(MAIN_TASK_MSG_CFG_SUBTYPE_SPEED_LEVEL, (uint32_t)&value);

    GWIN_DEBUG("%d", value);

    return value;
}

/**
 * @brief 行程最小值
 */
uint32_t gwin_get_stroke_min(void)
{
    uint32_t value = 0;
    gwin_main_cfg_get(MAIN_TASK_MSG_CFG_SUBTYPE_STROKE_MIN, (uint32_t)&value);

    GWIN_DEBUG("%d", value);

    return value;
}

/**
 * @brief 行程最大值
 */
uint32_t gwin_get_stroke_max(void)
{
    uint32_t value = 0;
    gwin_main_cfg_get(MAIN_TASK_MSG_CFG_SUBTYPE_STROKE_MAX, (uint32_t)&value);

    GWIN_DEBUG("%d", value);

    return value;
}

/**
 * @brief 干节点模式
 */
uint32_t gwin_get_node_mode(void)
{
    uint32_t value = 0;
    gwin_main_cfg_get(MAIN_TASK_MSG_CFG_SUBTYPE_NODE_MODE, (uint32_t)&value);

    GWIN_DEBUG("%d", value);

    return value;
}

/**
 * @brief 设备设置（隐藏某些功能）
 */
uint32_t gwin_get_product_cfg(void)
{
    uint32_t value = 0;
    gwin_main_cfg_get(MAIN_TASK_MSG_CFG_SUBTYPE_PRODUCT_CFG, (uint32_t)&value);

    GWIN_DEBUG("%d", value);

    return value;
}


/*-------------------------- END OF FILE ------------------------------------*/

